﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace TB_WS.Class
{
    public class Express_Push
    {
        public static int Insert_Push_Tid(int Seller_ID,string Tid,string WX_ID)
        {
            string sql = "insert into Push_Express values(" + Seller_ID + ",'" + Tid + "','" + WX_ID + "')";
            return Class.Unit.db_Conn.Nonquery(sql);
        }

        public static int get_Push_tid_count(int Seller_ID,string Tid)
        {
            string sql = "select count(*) from Push_Express where Tid='" + Tid + "' and Seller_ID=" + Seller_ID;
            return Convert.ToInt32(Class.Unit.db_Conn.scalar(sql));
        }

        public static DataSet Get_Express_List()
        {
            string sql = "select * from Push_Express order by id desc";
            return Class.Unit.db_Conn.select(sql);
        }

        public static int Delete_Push_Tid(int Seller_ID,string Tid)
        {
            string sql = "delete from Push_Express where Tid='" + Tid + "' and Seller_ID=" + Seller_ID;
            return Class.Unit.db_Conn.Nonquery(sql);
        }

        public static DataSet get_Express_Tid(int Seller_ID, string Tid)
        {
            string sql = "select * from Push_Express where Tid='" + Tid + "' and Seller_ID=" + Seller_ID;
            return Class.Unit.db_Conn.select(sql);
        }

        public static int insert_Push_Log(string Tid,string Push_String,string Push_Date_Time,string Push_WX_ID)
        {
            string sql = "insert into EX_Push_Log values('" + Tid + "','" + Push_String + "','" + Push_Date_Time + "','" + Push_WX_ID + "')";
            return Class.Unit.db_Conn.Nonquery(sql);
        }

        public static string get_last_Push_log(string Tid)
        {
            string sql = "select Push_String from EX_Push_Log where Tid='" + Tid + "' order by id desc";
            return Class.Unit.db_Conn.scalar(sql);
        }

        public static DataSet Get_Push_Log_use_tid(string Tid)
        {
            string sql = "select * from EX_Push_Log where Tid='" + Tid + "'";
            return Class.Unit.db_Conn.select(sql);
        }

        public static int Delete_WX_ID_Push(string WX_ID)
        {
            string sql = "delete from Push_Express where WX_ID='" + WX_ID + "'";
            return Class.Unit.db_Conn.Nonquery(sql);
        }
        
    }
}
